/*
 * Copyright (c) gitee.com/jiandong001.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import hilog from '@ohos.hilog';
import { ArkExecutor } from './ArkExecutor'
import { JavaScriptExecutorFactory } from '../../react/bridge/JavaScriptExecutorFactory'
import { JavaScriptExecutor, RuntimeConfig } from '../../react/bridge/JavaScriptExecutor'

export class ArkExecutorFactory implements JavaScriptExecutorFactory {

  private static readonly TAG = "React ArkExecutorFactory";
  private mConfig: RuntimeConfig;
  private mEnableDebugger: boolean;
  private mDebuggerName: string;

  public constructor(config?: RuntimeConfig) {
    this.mEnableDebugger = true;
    this.mDebuggerName = "";
    this.mConfig = config;
  }

  public create(): JavaScriptExecutor {
    hilog.error(0x0000, ArkExecutorFactory.TAG, '%{public}s', 'ArkExecutorFactory create');

    return new ArkExecutor(this.mConfig, this.mEnableDebugger, this.mDebuggerName);
  }


  public startSamplingProfiler() {
    throw new Error("Starting sampling profiler not supported on " + this.toString());
  }

  public stopSamplingProfiler(filename: string) {
    throw new Error("Stopping sampling profiler not supported on " + this.toString());
  }

  public toString(): string {
    return "JSIExecutor + HermesRuntime";
  }
}
